import 'package:zpp_sdzx/model/inventory.dart';

import '../model/danger2.dart';
import '../model/doc_review.dart';
import '../model/things.dart';
import '../pages/danger2/danger_add.dart';
import '../pages/danger2/danger_details.dart';
import '../pages/docreview/docreview_info.dart';
import '../pages/inspectreport/inspectReport_add.dart';
import '../pages/inspectreport/inspect_add_new.dart';
import '../pages/skddl2/skddl_info_home.dart';
import '../pages/things/inventory_add_0.dart';
import '../pages/things/things_add.dart';

import '../../model/cleanobjects.dart';
import '../../model/docsend.dart';
import '../../model/skddl2.dart';
import '../../pages/cleanobjects/cleanobjects_info.dart';
import '../../pages/docsend/docsend_info.dart';
import '../../spaces/report_space/report_add.dart';

import '../model/shipuse.dart';
import '../pages/shipuse/shipuse_huizhi_add.dart';

import '../pages/shipuse/shipuse_info_guanli.dart';
import '../pages/shipuse/shipuse_info_home.dart';

import '../model/danger.dart';
import '../pages/danger/danger_add.dart';
import '../pages/danger/danger_details.dart';

import '../model/stationcheck.dart';
import '../pages/station/stationcheck_add.dart';
import '../pages/station/stationcheck_info.dart';
import 'package:shared_preferences/shared_preferences.dart';

import '../pages/homex/upfile_list.dart';
import 'package:flutter/material.dart';
import '../model/jxgzp.dart';
import '../pages/jxgzp/jxgzp_info_home.dart';
import '../pages/skddl/skddl_list.dart';

import '../pages/xhss/xhsskd_add.dart';
import '../pages/xhss/xhsskd_list.dart';
import '../pages/xhss/xhsszt_list.dart';
import '../model/skddl.dart';
import '../pages/skddl/skddl_add.dart';

import '../pages/skddl/skddl_info_home.dart';

//import 'package:latlong/latlong.dart';
import '../model/recording.dart';
import '../model/station.dart';

import '../spaces/image_space/recod_image_scan.dart';
import '../spaces/image_space/record_list.dart';

import '../pages/station/station_details.dart';

import '../spaces/image_space/record_image_add.dart';

import '../pages/homex/download_list.dart';
import 'Helper.dart';
import 'uidata.dart';

//import 'package:station/ui/pages/audio_add.dart';

class RouteHelper {
  static void RecordImgList(BuildContext context, String SpaceId) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return RecordListPage(SpaceId, true);
    }));
  }

  static void StationInfoPage(BuildContext context, Station s1) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return StationPage(s1);
    }));
  }

  static void ShipUseHuiZhiAdd(
      BuildContext context, ShipUse stc1, VoidCallback added) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return ShipUseHuiZhiAddPage(stc1, added);
    }));
  }

  static void InspectAdd(BuildContext context, VoidCallback added) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return InspectAddNewPage();
    }));
  }

  static void InventoryAdd(
      BuildContext context, String title, int sType, VoidCallback added) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return InventoryAdd0Page(null, sType, null, title, added);
    }));
  }

  static void ShipUseGuanLiAdd(
      BuildContext context, ShipUse stc1, VoidCallback added) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return ShipUseGuanLiAddPage(stc1, added);
    }));
  }

  static void DangerInfoPage(BuildContext context, Danger s1) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return DangerDetailPage(s1);
    }));
  }

  static void Danger2InfoPage(BuildContext context, Danger2 s1) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return Danger2DetailPage(s1);
    }));
  }

  static void XHSSZTPage(BuildContext context, int typeId) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return XHSSZTListPage(typeId);
    }));
  }

  static void XHSSKDPage(BuildContext context, int typeId) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return XHSSKDListPage(typeId);
    }));
  }

  static void XHSSKDAdd(BuildContext context, int typeId) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return XHSSKDAddPage(typeId);
    }));
  }

  static void ThingsAdd(
      BuildContext context, Things? s1, RefrushCallback callback) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return ThingsAddPage(s1!, callback);
    }));
  }

  static void getSKDDLInfoPage(
      BuildContext context, SKDDL s1, RefrushCallback callback) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      //return  SKDDLInfoPage(s1,callback);
      return SKDDLInfoHomePage(s1, callback);
    }));
  }

  static void getSKDDL2InfoPage(
      BuildContext context, SKDDL2 s1, RefrushCallback callback) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      //return  SKDDLInfoPage(s1,callback);
      return SKDDL2InfoHomePage(s1, callback);
    }));
  }

  static void getShipUseInfoPage(
      BuildContext context, ShipUse s1, RefrushCallback callback) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      //return  SKDDLInfoPage(s1,callback);
      return ShipUseInfoHomePage(s1, callback);
    }));
  }

  static void getDocSendInfoPage(
      BuildContext context, DocSend s1, RefrushCallback callback) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      //return  SKDDLInfoPage(s1,callback);
      return DocSendInfoPage(s1, callback);
    }));
  }

  static void getDocReviewInfoPage(
      BuildContext context, DocReview s1, RefrushCallback callback) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      //return  SKDDLInfoPage(s1,callback);
      return DocReviewInfoPage(s1, callback);
    }));
  }

  static void getCleanInfoPage(
      BuildContext context, CleanObjects s1, RefrushCallback callback) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      //return  SKDDLInfoPage(s1,callback);
      return CleanInfoPage(s1, callback);
    }));
  }

  static void showBottomPanel(BuildContext context, Widget child) {
    showModalBottomSheet(
      isScrollControlled: true,
      context: context,
      //elevation: 5.0,
      builder: (BuildContext context) {
        return SingleChildScrollView(child: child);
      },
    );
  }

  static void getJXGZPInfoPage(
      BuildContext context, JXGZP s1, RefrushCallback callback) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      //return  SKDDLInfoPage(s1,callback);
      return JXGZPInfoHomePage(s1, callback);
    }));
  }

  // static void MyMapPage(BuildContext context, double lat,double lng) {
  //    Navigator.push(context, MaterialPageRoute(builder: (context) {
  //      return  MyMap(location: LatLng(lat, lng),);
  //    }));
  //  }

  static void DownloadList(BuildContext context) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return Scaffold(
          appBar: AppBar(
            title: Text("下载列表"),
          ),
          body: DownLoadBookPage());
    }));
  }

  static void UploadList(BuildContext context) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return Scaffold(
          appBar: AppBar(
            title: Text("上传列表"),
          ),
          body: UpFileBookPage());
    }));
  }

  static void RecordImgScan(BuildContext context, Recording U1) {
    // Navigator.push(context, MaterialPageRoute(builder: (context) {
    //return  RecordImageScanPage(U1);
    // }));
  }

  static void ShowRoute(BuildContext context, String route) {
    Navigator.of(context).pushNamed(route);
  }

  static void ShowPage(BuildContext context, Widget child) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return child;
    }));
  }

  static void MyFileSpace(BuildContext context) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return DownLoadBookPage();
    }));
  }

  static void RecordImgAdd(
      BuildContext context, String spaceId, RecordAddCallback added) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return ImgRecordAddPage(spaceId, added);
    }));
  }

  static void StationCheckAdd(BuildContext context, Station? station,
      StationCheck? stc1, VoidCallback added) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return StationCheckAddPage(
          station as Station, stc1 as StationCheck, added);
    }));
  }

  static void DangerAdd(
      BuildContext context, String sID, String sNM, VoidCallback added) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return DangerAddPage(sID, sNM, added);
    }));
  }

  static void Danger2Add(BuildContext context, VoidCallback added) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return Danger2AddPage(added);
    }));
  }

  static void StationCheckInfo(BuildContext context, Station station,
      StationCheck stc1, VoidCallback added) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return StationCheckInfoPage(station, stc1, added);
    }));
  }

  static void ReportAdd(
      BuildContext context, String spaceId, VoidCallback added) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return ReportAddPage(spaceId, added);
    }));
  }

  static void SKDDLAdd(BuildContext context) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return SKDDLAddPage();
    }));
  }

  static void exitLogin(BuildContext context) async {
    UIData.CurrentUser = null;
    SharedPreferences prefs = await SharedPreferences.getInstance();
    prefs.remove("username");
    prefs.remove("password");
    prefs.remove("phone");
    Navigator.of(context)
        .pushNamedAndRemoveUntil(UIData.loginRoute, ModalRoute.withName('/'));
  }
}
